Optimize Claude Code hooks to only run on src/ changes#5952
Conversation
Updated three Claude Code hooks to skip validation when changes are outside the src/ directory: - check-as-any-pre.py: Exit early if file is not in src/ - graphql-check.py: Filter to only check src/ files - validation-check.sh: Skip type checking and linting if no src/ changes This optimization reduces unnecessary hook execution time when working on documentation, configuration, or other non-source files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull Request Overview
Optimizes Claude Code validation hooks to skip execution when changes are outside the src/ directory, reducing unnecessary validation time for non-source file modifications.
- Added early exit conditions to check if files are in
src/directory before running validation - Implemented filtering logic to only process source files
- Added informational messaging when validation is skipped
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| .claude/hooks/validation-check.sh | Added git diff check to skip validation when no src/ changes detected |
| .claude/hooks/graphql-check.py | Added filtering to only check GraphQL files within src/ directory |
| .claude/hooks/check-as-any-pre.py | Added early exit for files outside src/ directory |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Addressed Copilot review feedback: - Use Path.parts for more precise path matching instead of string operations - Prevents false positives from paths like 'docs/src_files/' or 'test/mysrc/' - Fix graphql-check.py to use filtered src_files list consistently 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5952 +/- ##
=======================================
Coverage 40.06% 40.06%
=======================================
Files 2473 2473
Lines 40229 40229
Branches 8854 8854
=======================================
Hits 16119 16119
Misses 24083 24083
Partials 27 27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
src/directoryChanges
check-as-any-pre.py
src/directorygraphql-check.py
src/directorysrc/files modifiedvalidation-check.sh
src/changes before running type checking and lintingTest plan
src/directory - hooks run as expectedsrc/- hooks skip appropriately🤖 Generated with Claude Code